<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

use App\Common\Middleware\AllowOriginMiddleware;
use App\Common\Middleware\CheckSiteOpenMiddleware;
use Hyperf\HttpServer\Router\Router;

Router::addRoute(['GET', 'POST', 'HEAD'], '/', 'App\Controller\IndexController@index');

Router::get('/favicon.ico', function () {
    return '';
});



Router::addGroup('/api/', function () {
    $path = BASE_PATH . DIRECTORY_SEPARATOR . 'route' . DIRECTORY_SEPARATOR . 'api';
    $files = scandir($path);
    foreach ($files as $file) {
        if ($file != '.' && $file != '..') {
            include $path . DIRECTORY_SEPARATOR . $file;
        }
    }
}, [
    'middleware' => [
        AllowOriginMiddleware::class,
        CheckSiteOpenMiddleware::class,
    ],
]);

// Router::addGroup('/sys/', function () {
//    $path = BASE_PATH . DIRECTORY_SEPARATOR . 'route' . DIRECTORY_SEPARATOR . 'admin';
//    $files = scandir($path);
//    foreach ($files as $file) {
//        if ($file != '.' && $file != '..') {
//            include $path . DIRECTORY_SEPARATOR . $file;
//        }
//    }
// }, [
//    'middleware' => [
//        AllowOriginMiddleware::class,
//        CheckSiteOpenMiddleware::class,
//    ],
// ]);

// Router::addGroup('/mer/', function () {
//    $path = BASE_PATH . DIRECTORY_SEPARATOR . 'route' . DIRECTORY_SEPARATOR . 'merchant';
//    $files = scandir($path);
//    foreach ($files as $file) {
//        if ($file != '.' && $file != '..') {
//            include $path . DIRECTORY_SEPARATOR . $file;
//        }
//    }
// }, [
//    'middleware' => [
//        AllowOriginMiddleware::class,
//        CheckSiteOpenMiddleware::class,
//    ],
// ]);
